-- 创建数据库（如果不存在）
CREATE DATABASE IF NOT EXISTS aegis DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- 使用数据库
USE aegis;

/*
 Navicat Premium Dump SQL

 Source Server         : localhost-aegis
 Source Server Type    : MySQL
 Source Server Version : 80032 (8.0.32)
 Source Host           : localhost:3306
 Source Schema         : aegis

 Target Server Type    : MySQL
 Target Server Version : 80032 (8.0.32)
 File Encoding         : 65001

 Date: 27/05/2025 11:11:13
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for auth_api_permission
-- ----------------------------
DROP TABLE IF EXISTS `auth_api_permission`;
CREATE TABLE `auth_api_permission` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `api` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api地址',
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'api名称',
  `source` int NOT NULL DEFAULT '0' COMMENT '接口来源: 0其他系统，1aegis系统',
  `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '接口方法：大小写GET、POST、PUT等HTTP方法，ALL则全方法匹配',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_api_permission
-- ----------------------------
BEGIN;
INSERT INTO `auth_api_permission` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `api`, `name`, `source`, `method`) VALUES ('1900065138069839874', '2022-08-19 16:51:00', '2022-08-19 16:51:00', 'admin', 'admin', 'aegis管理平台接口', NULL, 0, '/aegis-manage/sys/auth/login', 'aegis管理平台登录', 1, 'POST');
INSERT INTO `auth_api_permission` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `api`, `name`, `source`, `method`) VALUES ('1914199714820022273', '2025-05-09 11:07:10', '2025-04-21 14:09:11', NULL, 'admin', '演示demo', NULL, 0, '/demo1/auth/login', '演示demo1-用户登录', 0, 'GET');
INSERT INTO `auth_api_permission` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `api`, `name`, `source`, `method`) VALUES ('1920678624090640385', '2025-05-09 11:14:03', '2025-05-09 11:14:03', NULL, 'admin', '演示签名访问该接口', NULL, 0, '/demo2/app/demo1', '演示demo2-签名接口1', 0, 'GET');
INSERT INTO `auth_api_permission` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `api`, `name`, `source`, `method`) VALUES ('1920681212605362178', '2025-05-09 14:42:29', '2025-05-09 11:24:20', NULL, 'admin', '接口地址一样，方法不同', NULL, 0, '/demo2/app/demo1', '演示demo2-签名接口2', 0, 'DELETE');
INSERT INTO `auth_api_permission` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `api`, `name`, `source`, `method`) VALUES ('1920731187068923905', '2025-05-09 14:43:04', '2025-05-09 14:42:55', NULL, 'admin', '签名访问POST方法', NULL, 0, '/demo2/app/demo2', '演示demo2-签名接口3', 0, 'POST');
COMMIT;

-- ----------------------------
-- Table structure for auth_api_permission_group
-- ----------------------------
DROP TABLE IF EXISTS `auth_api_permission_group`;
CREATE TABLE `auth_api_permission_group` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `group_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限组key',
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限名称',
  `status` int NOT NULL DEFAULT '0' COMMENT '状态，0正常，1禁用',
  `source` int NOT NULL DEFAULT '0' COMMENT '接口来源: 0其他系统，1aegis系统',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_api_permission_group
-- ----------------------------
BEGIN;
INSERT INTO `auth_api_permission_group` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `group_key`, `name`, `status`, `source`) VALUES ('1902608567942995971', '2025-03-20 14:30:06', '2025-03-20 14:30:06', NULL, 'admin', 'aegis权限组', NULL, 0, 'aegis', 'aegis权限组', 0, 1);
INSERT INTO `auth_api_permission_group` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `group_key`, `name`, `status`, `source`) VALUES ('1912698255251087361', '2025-04-17 10:42:55', '2025-04-17 10:42:55', NULL, 'admin', '这是测试使用的权限组', NULL, 0, 'test_group_key', '测试权限组', 0, 0);
COMMIT;

-- ----------------------------
-- Table structure for auth_app
-- ----------------------------
DROP TABLE IF EXISTS `auth_app`;
CREATE TABLE `auth_app` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `status` int NOT NULL DEFAULT '0' COMMENT '状态，0正常，1停用',
  `app_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应用id',
  `app_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应用名称',
  `app_secret` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密钥',
  `source` int NOT NULL DEFAULT '0' COMMENT '接口来源: 0其他系统，1aegis系统',
  PRIMARY KEY (`id`),
  UNIQUE KEY `sys_app_app_id_index` (`app_id`),
  UNIQUE KEY `sys_app_name_index` (`app_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_app
-- ----------------------------
BEGIN;
INSERT INTO `auth_app` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `status`, `app_id`, `app_name`, `app_secret`, `source`) VALUES ('1904334068034236417', '2025-04-11 13:53:29', '2025-03-25 08:46:37', NULL, 'admin', '演示demo', NULL, 0, 0, '71rv7uk9bdgtbnwop80sh7wxato', '测试应用', '9563abdf8c3425f8e8490704cded8ce3206a7a66193ef31f3c6a1602ba57105f', 0);
INSERT INTO `auth_app` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `status`, `app_id`, `app_name`, `app_secret`, `source`) VALUES ('aegis', '2025-02-24 10:40:46', '2025-02-24 10:40:46', NULL, 'admin', NULL, NULL, 0, 0, 'aegis', 'ageis管理平台', '87dde8ffd000904242b13045272fe3e4d5a6c33ff6bae4d71f27ef3b60fac70d', 1);
COMMIT;

-- ----------------------------
-- Table structure for auth_app_permission_assignment
-- ----------------------------
DROP TABLE IF EXISTS `auth_app_permission_assignment`;
CREATE TABLE `auth_app_permission_assignment` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `permission_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '权限id',
  `sys_app_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应用表主键id',
  `permission_group_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '权限组id',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_app_permission_assignment
-- ----------------------------
BEGIN;
INSERT INTO `auth_app_permission_assignment` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `sys_app_id`, `permission_group_id`) VALUES ('1904069718591959043', '2025-03-24 15:16:11', '2025-03-24 15:16:11', NULL, 'admin', 'aegis权限绑定', NULL, 0, NULL, 'aegis', '1902608567942995971');
INSERT INTO `auth_app_permission_assignment` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `sys_app_id`, `permission_group_id`) VALUES ('1912700548218363905', '2025-04-17 10:52:02', '2025-04-17 10:52:02', NULL, 'admin', NULL, NULL, 0, NULL, '1904334068034236417', '1912698255251087361');
COMMIT;

-- ----------------------------
-- Table structure for auth_app_permission_group_mapping
-- ----------------------------
DROP TABLE IF EXISTS `auth_app_permission_group_mapping`;
CREATE TABLE `auth_app_permission_group_mapping` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `permission_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限id',
  `permission_group_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限组id',
  `type` int NOT NULL COMMENT '鉴权类型: 0白名单，1摘要鉴权',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_app_permission_group_mapping
-- ----------------------------
BEGIN;
INSERT INTO `auth_app_permission_group_mapping` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `permission_group_id`, `type`) VALUES ('1903989616508162050', '2025-03-24 09:57:54', '2025-03-24 09:57:54', NULL, 'admin', 'aegis权限组绑定', NULL, 0, '1900065138069839874', '1902608567942995971', 0);
INSERT INTO `auth_app_permission_group_mapping` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `permission_group_id`, `type`) VALUES ('1914199891400220673', '2025-04-21 14:09:53', '2025-04-21 14:09:53', NULL, 'admin', NULL, NULL, 0, '1914199714820022273', '1912698255251087361', 0);
INSERT INTO `auth_app_permission_group_mapping` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `permission_group_id`, `type`) VALUES ('1920732833341632513', '2025-05-09 14:49:28', '2025-05-09 14:49:28', NULL, 'admin', NULL, NULL, 0, '1920731187068923905', '1912698255251087361', 1);
INSERT INTO `auth_app_permission_group_mapping` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `permission_group_id`, `type`) VALUES ('1920732833370992641', '2025-05-09 14:49:28', '2025-05-09 14:49:28', NULL, 'admin', NULL, NULL, 0, '1920681212605362178', '1912698255251087361', 1);
INSERT INTO `auth_app_permission_group_mapping` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `permission_group_id`, `type`) VALUES ('1920732833391964161', '2025-05-09 14:49:28', '2025-05-09 14:49:28', NULL, 'admin', NULL, NULL, 0, '1920678624090640385', '1912698255251087361', 1);
COMMIT;

-- ----------------------------
-- Table structure for auth_user_info
-- ----------------------------
DROP TABLE IF EXISTS `auth_user_info`;
CREATE TABLE `auth_user_info` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `app_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应用id',
  `sys_app_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应用主键id',
  `user_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户id',
  `account` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户账户',
  `last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间\n',
  `last_login_ip` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '最后登录的ip',
  `last_login_device` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '最后登录的设备',
  PRIMARY KEY (`id`),
  KEY `auth_user_info_app_id_user_id_index` (`app_id`,`user_id`),
  KEY `auth_user_info_sys_app_id_id_index` (`sys_app_id`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_user_info
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for auth_user_permission_api
-- ----------------------------
DROP TABLE IF EXISTS `auth_user_permission_api`;
CREATE TABLE `auth_user_permission_api` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `api` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api地址',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '接口名称',
  `group_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '所属分组的id',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_user_permission_api
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for auth_user_permission_group
-- ----------------------------
DROP TABLE IF EXISTS `auth_user_permission_group`;
CREATE TABLE `auth_user_permission_group` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `group_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限组id，开发者定义',
  `group_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限组名称',
  `group_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限组key',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of auth_user_permission_group
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `menu_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '菜单名称',
  `parent_id` int DEFAULT NULL COMMENT '父菜单id',
  `path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '路由路径',
  `priority` int NOT NULL DEFAULT '0' COMMENT '排序',
  `menu_type` int NOT NULL COMMENT '菜单类型，1目录，2菜单，3按钮',
  `status` int NOT NULL DEFAULT '0' COMMENT '菜单状态，0正常，1停用',
  `icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '图标'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_menu
-- ----------------------------
BEGIN;
INSERT INTO `sys_menu` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `menu_name`, `parent_id`, `path`, `priority`, `menu_type`, `status`, `icon`) VALUES ('1853248727934881793', '2024-11-04 09:31:43', '2024-11-04 09:31:43', NULL, 'admin', NULL, NULL, 0, '首页', NULL, NULL, 0, 1, 0, NULL);
COMMIT;

-- ----------------------------
-- Table structure for sys_menu_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu_permission`;
CREATE TABLE `sys_menu_permission` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `permission_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限id',
  `menu_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '菜单id'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_menu_permission
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_permission`;
CREATE TABLE `sys_permission` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `permission` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限key',
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限名称',
  `api` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api地址',
  `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '接口方法：大小写GET、POST、PUT等HTTP方法，ALL则全方法匹配',
  `status` int NOT NULL DEFAULT '0' COMMENT '状态0正常1停用',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_permission
-- ----------------------------
BEGIN;
INSERT INTO `sys_permission` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission`, `name`, `api`, `method`, `status`) VALUES ('1897476756145401857', '2025-03-06 10:38:07', '2025-03-06 10:38:07', NULL, 'admin', NULL, NULL, 0, 'sys:menu:tree', '菜单树', '/aegis-manage/menu/tree', 'GET', 0);
COMMIT;

-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `role_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色key',
  `role_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色名称',
  `status` int NOT NULL DEFAULT '0' COMMENT '状态：0正常，1停用',
  `priority` int NOT NULL DEFAULT '0' COMMENT '角色排序'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_role
-- ----------------------------
BEGIN;
INSERT INTO `sys_role` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `role_key`, `role_name`, `status`, `priority`) VALUES ('1778237581039464450', '2024-04-11 09:44:12', '2024-04-11 09:44:12', NULL, NULL, '管理员', NULL, 0, 'admin', '系统管理员', 0, 0);
INSERT INTO `sys_role` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `role_key`, `role_name`, `status`, `priority`) VALUES ('1848253149610012673', '2024-10-21 14:41:05', '2024-10-21 14:41:05', NULL, 'admin', '普通用户', NULL, 0, 'user', '普通用户', 0, 0);
COMMIT;

-- ----------------------------
-- Table structure for sys_role_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_menu`;
CREATE TABLE `sys_role_menu` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `role_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色id',
  `menu_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '菜单id'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_role_menu
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_permission`;
CREATE TABLE `sys_role_permission` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `permission_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '权限ID',
  `role_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色ID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_role_permission
-- ----------------------------
BEGIN;
INSERT INTO `sys_role_permission` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `permission_id`, `role_id`) VALUES ('1853322179297083393', '2024-11-04 14:23:35', '2024-11-04 14:23:35', NULL, 'admin', NULL, NULL, 0, '1897476756145401857', '1848253149610012673');
COMMIT;

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `username` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户名，同时也是账户名',
  `password` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密码，这里采用sha1进行转换',
  `nickname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户昵称',
  `mobile` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号码',
  `sex` int DEFAULT NULL COMMENT '用户性别: 0未知，1男，2女',
  `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户头像',
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户邮箱',
  `last_login_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '最后登录IP',
  `last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
  `status` int NOT NULL DEFAULT '0' COMMENT '帐号状态'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_user
-- ----------------------------
BEGIN;
INSERT INTO `sys_user` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `username`, `password`, `nickname`, `mobile`, `sex`, `avatar`, `email`, `last_login_ip`, `last_login_time`, `status`) VALUES ('admin', '2024-01-01 00:00:00', '2024-01-01 00:00:00', NULL, NULL, '初始化系统管理员', NULL, 0, 'admin', '70890c803742953bce52674a9b80a2c1', 'admin', 'admin', 0, 'https://yx.ventiwwx.top/images/2.png', 'admin@gmail', NULL, NULL, 0);
COMMIT;

-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role` (
  `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键ID',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `extra` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '额外信息',
  `delete_flag` int NOT NULL DEFAULT '0' COMMENT '删除标识，0不删除，1删除',
  `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户id',
  `role_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色id',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of sys_user_role
-- ----------------------------
BEGIN;
INSERT INTO `sys_user_role` (`id`, `update_time`, `create_time`, `update_by`, `create_by`, `remark`, `extra`, `delete_flag`, `user_id`, `role_id`) VALUES ('1778261205242826754', '2024-04-11 11:18:04', '2024-04-11 11:18:04', NULL, NULL, NULL, NULL, 0, 'admin', '1778237581039464450');
COMMIT;

-- ----------------------------
-- Procedure structure for AddCommentsToCommonFields
-- ----------------------------
DROP PROCEDURE IF EXISTS `AddCommentsToCommonFields`;
delimiter ;;
CREATE PROCEDURE `AddCommentsToCommonFields`()
BEGIN
    DECLARE done INT DEFAULT FALSE;
    DECLARE tbl_name VARCHAR(255);

    DECLARE cur CURSOR FOR
        SELECT TABLE_NAME
        FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_SCHEMA = 'wx_auth_gateway';

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

    OPEN cur;

    read_loop: LOOP
        FETCH cur INTO tbl_name;
        IF done THEN
            LEAVE read_loop;
        END IF;

        SET @sql1 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `id` varchar(50) NOT NULL COMMENT "主键ID";');
        SET @sql2 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `update_time` datetime NULL COMMENT "更新时间";');
        SET @sql3 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `create_time` datetime NULL COMMENT "创建时间";');
        SET @sql4 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `update_by` varchar(50) NULL COMMENT "更新人";');
        SET @sql5 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `create_by` varchar(50) NULL COMMENT "创建人";');
        SET @sql6 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `remark` varchar(255) NULL COMMENT "备注";');
        SET @sql7 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `extra` varchar(255) NULL COMMENT "额外信息";');
        SET @sql8 = CONCAT('ALTER TABLE `', tbl_name, '` MODIFY `delete_flag` int default 0 not null COMMENT "删除标识，0不删除，1删除";');

        PREPARE stmt1 FROM @sql1; EXECUTE stmt1; DEALLOCATE PREPARE stmt1;
        PREPARE stmt2 FROM @sql2; EXECUTE stmt2; DEALLOCATE PREPARE stmt2;
        PREPARE stmt3 FROM @sql3; EXECUTE stmt3; DEALLOCATE PREPARE stmt3;
        PREPARE stmt4 FROM @sql4; EXECUTE stmt4; DEALLOCATE PREPARE stmt4;
        PREPARE stmt5 FROM @sql5; EXECUTE stmt5; DEALLOCATE PREPARE stmt5;
        PREPARE stmt6 FROM @sql6; EXECUTE stmt6; DEALLOCATE PREPARE stmt6;
        PREPARE stmt7 FROM @sql7; EXECUTE stmt7; DEALLOCATE PREPARE stmt7;
        PREPARE stmt8 FROM @sql8; EXECUTE stmt8; DEALLOCATE PREPARE stmt8;

    END LOOP;

    CLOSE cur;
END
;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;
